import Vue from 'vue';
import Router from 'vue-router';
Vue.use(Router);

export const constantRoutes = [
  {
    path: '/',
    name: '/',
    component: () => import('@/views/login'),
    meta: {
      tabindex: 0,
      hidehead: 'hidehead',
      hideai: 'hideai',
    },
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/login'),
    meta: {
      tabindex: 0,
      hidehead: 'hidehead',
      hideai: 'hideai',
    },
  },
  {
    path: '/index',
    name: 'index',
    component: () => import('@/views/image/index'),
    meta: {
      tabindex: 1,
    },
  },
  {
    path: '/imagedetail',
    name: 'imagedetail',
    component: () => import('@/views/image/detail'),
    meta: {
      tabindex: 1,
      hidehead: 'hidehead',
    },
  },

  {
    path: '/case',
    name: 'case',
    component: () => import('@/views/case/index'),
    meta: {
      tabindex: 2,
    },
  },
  {
    path: '/caseimage',
    name: 'caseimage',
    component: () => import('@/views/case/image'),
    meta: {
      tabindex: 2,
      hidehead: 'hidehead',
      hideai: 'hideai',
    },
  },

  {
    path: '/casedetail',
    name: 'casedetail',
    component: () => import('@/views/case/detail'),
    meta: {
      tabindex: 2,
      hidehead: 'hidehead',
    },
  },
  {
    path: '/exams',
    name: 'exams',
    component: () => import('@/views/exams/index'),
    meta: {
      tabindex: 3,
    },
  },
  {
    path: '/examdetail',
    name: 'examdetail',
    component: () => import('@/views/exams/detail'),
    meta: {
      tabindex: 3,
      hidehead: 'hidehead',
    },
  },
  {
    path: '/examresult',
    name: 'examresult',
    component: () => import('@/views/exams/result'),
    meta: {
      tabindex: 3,
      hidehead: 'hidehead',
    },
  },
  {
    path: '/center',
    name: 'center',
    component: () => import('@/views/center/index'),
    meta: {
      tabindex: 0,
    },
  },
  {
    path: '/centercase',
    name: 'centercase',
    component: () => import('@/views/center/casesdetail'),
    meta: {
      tabindex: 0,
      hidehead: 'hidehead',
    },
  },
  {
    path: '/redirect',
    name: 'redirect',
    component: () => import('@/components/redirect'),
    meta: {
      tabindex: 0,
      hidehead: 'hidehead',
    },
  },
  {
    path: '/atlas',
    name: 'atlas',
    component: () => import('@/views/image/atlas'),
    meta: {
      tabindex: 1,
      hideai: 'hideai',
      hidehead: 'hidehead',
    },
  },
];

const createRouter = () =>
  new Router({
    scrollBehavior: () => ({
      y: 0,
    }),
    routes: constantRoutes,
  });

const router = createRouter();

export function resetRouter() {
  const newRouter = createRouter();
  router.matcher = newRouter.matcher; // reset router
}

export default router;
